package com.ruoyi.project.poem.poemuserinfo.service.impl;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.poem.poemuserinfo.domain.PoemUserInfo;
import com.ruoyi.project.poem.poemuserinfo.mapper.PoemUserInfoMapper;
import com.ruoyi.project.poem.poemuserinfo.service.IPoemUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 诗词用户信息Service业务层处理
 *
 * @author shixiangwen
 * @date 2022-10-11
 */
@Service
@DataSource(DataSourceType.POEMBBS)
public class PoemUserInfoServiceImpl implements IPoemUserInfoService {

    @Autowired
    private PoemUserInfoMapper poemUserInfoMapper;

    /**
     * 查询诗词用户信息
     *
     * @param id 诗词用户信息ID
     * @return 诗词用户信息
     */
    @Override
    public PoemUserInfo selectPoemUserInfoById(Long id) {
        return poemUserInfoMapper.selectPoemUserInfoById(id);
    }

    /**
     * 查询诗词用户信息列表
     *
     * @param poemUserInfo 诗词用户信息
     * @return 诗词用户信息
     */
    @Override
    public List<PoemUserInfo> selectPoemUserInfoList(PoemUserInfo poemUserInfo) {
        return poemUserInfoMapper.selectPoemUserInfoList(poemUserInfo);
    }

    @Override
    public PoemUserInfo selectPoemUserInfoOne(String userId) {
        PoemUserInfo poemUserInfo = new PoemUserInfo();
        poemUserInfo.setUserId(userId);
        List<PoemUserInfo> poemUserInfos = poemUserInfoMapper.selectPoemUserInfoList(poemUserInfo);
        if (!poemUserInfos.isEmpty()) {
            return poemUserInfos.get(0);
        }
        return null;
    }

    /**
     * 新增诗词用户信息
     *
     * @param poemUserInfo 诗词用户信息
     * @return 结果
     */
    @Override
    public int insertPoemUserInfo(PoemUserInfo poemUserInfo) {
        return poemUserInfoMapper.insertPoemUserInfo(poemUserInfo);
    }

    /**
     * 修改诗词用户信息
     *
     * @param poemUserInfo 诗词用户信息
     * @return 结果
     */
    @Override
    public int updatePoemUserInfo(PoemUserInfo poemUserInfo) {
        return poemUserInfoMapper.updatePoemUserInfo(poemUserInfo);
    }

    /**
     * 删除诗词用户信息对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deletePoemUserInfoByIds(String ids) {
        return poemUserInfoMapper.deletePoemUserInfoByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除诗词用户信息信息
     *
     * @param id 诗词用户信息ID
     * @return 结果
     */
    @Override
    public int deletePoemUserInfoById(Long id) {
        return poemUserInfoMapper.deletePoemUserInfoById(id);
    }
}
